#include <iostream>

int const maxn = 10000000;
int f[maxn];

int dfs(int x)
{
	if (!x) return 0;
	if (f[x]) return f[x];
	int tmp = 1<<20;
	for (int i = 1; 3*i*(i-1) + 1 <= x; i++) {
		tmp = std::min(tmp, dfs(x - (3*i*(i-1)) - 1) + 1);
	}
	return f[x] = tmp;
}


int main()
{
	int n = maxn;
	for (int i = 1; i < n; i++) {
		int t = dfs(i);
		if (t > 8) std::cout << i << ' ' << t << '\n';
		//std::cout << dfs(i) << '\n';
	}
}


